package com.swsc.solarverse.service.openapi.impl;


import com.swsc.solarverse.cmd.DefectLeIvdataQueryCmdExe;
import com.swsc.solarverse.cmd.DefectPageQueryCmdExe;
import com.swsc.solarverse.common.model.PageInfo;
import com.swsc.solarverse.model.req.DefectQueryReqVO;
import com.swsc.solarverse.model.res.OpenApiDefectLeDetailResVO;
import com.swsc.solarverse.model.res.StationDefectResVO;
import com.swsc.solarverse.service.openapi.OpenDefectService;

import java.util.List;

/**
 * @Author chencl
 * @Date 2024/4/19 10:30
 * @Version 1.0
 * @Description
 */
@org.springframework.stereotype.Service
public class OpenDefectServiceImpl implements OpenDefectService {
    private final DefectPageQueryCmdExe defectPageQueryCmdExe;
    private final DefectLeIvdataQueryCmdExe defectLeIvdataQueryCmdExe;

    public OpenDefectServiceImpl(DefectPageQueryCmdExe defectPageQueryCmdExe,
                                 DefectLeIvdataQueryCmdExe defectLeIvdataQueryCmdExe) {
        this.defectPageQueryCmdExe = defectPageQueryCmdExe;
        this.defectLeIvdataQueryCmdExe = defectLeIvdataQueryCmdExe;
    }

    @Override
    public PageInfo<StationDefectResVO> page(DefectQueryReqVO reqVo, Integer pageNo, Integer pageSize) {
        if(null == pageNo){
            pageNo = 1;
        }
        if(null == pageSize){
            pageSize = 10;
        }
        if(null == reqVo.getPageNo()){
            reqVo.setPageNo(pageNo);
        }
        if(null == reqVo.getPageSize()){
            reqVo.setPageSize(pageSize);
        }
        return defectPageQueryCmdExe.execute(reqVo);
    }

    @Override
    public List<OpenApiDefectLeDetailResVO> leDetails(DefectQueryReqVO reqVo) {
        return defectLeIvdataQueryCmdExe.execute(reqVo);
    }
}
